<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>坦克大战 - 房间列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f0f0f0;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
        }
        .container {
            width: 90%;
            max-width: 800px;
            margin: 20px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        .room-list {
            margin-top: 20px;
        }
        .room-item {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: center;
            padding: 15px;
            border-bottom: 1px solid #eee;
        }
        .room-item:last-child {
            border-bottom: none;
        }
        .room-name {
            font-weight: bold;
            font-size: 18px;
        }
        .room-info {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin: 5px 0;
        }
        .player-count, .room-status {
            color: #666;
        }
        .join-btn {
            padding: 8px 15px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            margin: 5px 0;
            min-width: 80px;
        }
        .join-btn:hover {
            background-color: #45a049;
        }
        .join-btn:disabled {
            background-color: #cccccc;
            cursor: not-allowed;
        }
        .game-started {
            background-color: #f9f9f9;
        }
        .create-room {
            margin-top: 20px;
            padding: 20px;
            background-color: #f9f9f9;
            border-radius: 5px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .btn-group {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            margin-top: 20px;
            gap: 10px;
        }
        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
        }
        .btn-primary {
            background-color: #4CAF50;
            color: white;
        }
        .btn-secondary {
            background-color: #2196F3;
            color: white;
        }
        .btn:hover {
            opacity: 0.9;
        }
        .no-rooms {
            text-align: center;
            padding: 20px;
            color: #666;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>坦克大战 - 房间列表</h1>
        
        <div class="btn-group">
            <button id="refreshButton" class="btn btn-secondary">刷新房间列表</button>
            <button id="backButton" class="btn btn-secondary">返回首页</button>
        </div>
        
        <div id="roomList" class="room-list">
            <!-- 房间列表将通过JavaScript动态生成 -->
        </div>
        
        <div class="create-room">
            <h2>创建新房间</h2>
            <form id="createRoomForm">
                <div class="form-group">
                    <label for="playerName">玩家名称:</label>
                    <input type="text" id="playerName" required placeholder="输入您的名称">
                </div>
                
                <!-- 移除颜色选择，将由系统自动分配 -->
                
                <button type="submit" class="btn btn-primary">创建房间</button>
            </form>
        </div>
    </div>

    <!-- 引入Socket.io客户端库 -->
    <script src="/socket.io/socket.io.js"></script>
    
    <!-- 引入房间管理脚本 -->
    <script src="/js/rooms.js"></script>
</body>
</html>